package graphics.tools;

import java.util.ArrayList;

import javax.media.j3d.Bounds;

/**
 * For keeping track of objects in universe and calculating collisions.
 * 
 * @author: Eirik Vigeland
 * @version: %I%, %G%
 */
public class CollisionDetection extends ArrayList<Bounds> {

	private static final long serialVersionUID = 1L;

	/**
	 * Returns true if a collision occurs with the input bound and the bounds of
	 * objects in the universe.
	 * 
	 * @param bounds
	 *            The bounds to check for collision
	 * @return True if a collision occurs
	 */
	public boolean isColliding(Bounds bounds) {
		boolean result = false;
		for (int i = 0; i < size(); i++) {
			if (!bounds.equals(get(i))) {
				if (bounds.intersect(get(i))) {
					result = true;
				}
			}
		}
		return result;
	}
}
